home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / AppleEvents.p < prev    next >
Encoding:
Text File  |  1997-08-12  |  13.7 KB  |  353 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        AppleEvents.p
  3.  
  4.      Contains:    AppleEvent Package Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1989-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT AppleEvents;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __APPLEEVENTS__}
  28. {$SETC __APPLEEVENTS__ := 1}
  29.  
  30. {$I+}
  31. {$SETC AppleEventsIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __MIXEDMODE__}
  38. {$I MixedMode.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __NOTIFICATION__}
  41. {$I Notification.p}
  42. {$ENDC}
  43. {$IFC UNDEFINED __EVENTS__}
  44. {$I Events.p}
  45. {$ENDC}
  46. {
  47.     Note:    The functions and types for the building and parsing AppleEvent  
  48.             messages has moved to AEDataModel.h
  49. }
  50. {$IFC UNDEFINED __AEDATAMODEL__}
  51. {$I AEDataModel.p}
  52. {$ENDC}
  53.  
  54.  
  55. {$PUSH}
  56. {$ALIGN MAC68K}
  57. {$LibExport+}
  58.  
  59.  
  60. CONST
  61.                                                                 {  Keywords for Apple event parameters  }
  62.     keyDirectObject                = '----';
  63.     keyErrorNumber                = 'errn';
  64.     keyErrorString                = 'errs';
  65.     keyProcessSerialNumber        = 'psn ';                        {  Keywords for special handlers  }
  66.     keyPreDispatch                = 'phac';                        {  preHandler accessor call  }
  67.     keySelectProc                = 'selh';                        {  more selector call  }
  68.                                                                 {  Keyword for recording  }
  69.     keyAERecorderCount            = 'recr';                        {  available only in vers 1.0.1 and greater  }
  70.                                                                 {  Keyword for version information  }
  71.     keyAEVersion                = 'vers';                        {  available only in vers 1.0.1 and greater  }
  72.  
  73. { Event Class }
  74.     kCoreEventClass                = 'aevt';
  75.  
  76. { Event ID’s }
  77.     kAEOpenApplication            = 'oapp';
  78.     kAEOpenDocuments            = 'odoc';
  79.     kAEPrintDocuments            = 'pdoc';
  80.     kAEQuitApplication            = 'quit';
  81.     kAEAnswer                    = 'ansr';
  82.     kAEApplicationDied            = 'obit';
  83.  
  84. { Constants for recording }
  85.     kAEStartRecording            = 'reca';                        {  available only in vers 1.0.1 and greater  }
  86.     kAEStopRecording            = 'recc';                        {  available only in vers 1.0.1 and greater  }
  87.     kAENotifyStartRecording        = 'rec1';                        {  available only in vers 1.0.1 and greater  }
  88.     kAENotifyStopRecording        = 'rec0';                        {  available only in vers 1.0.1 and greater  }
  89.     kAENotifyRecording            = 'recr';                        {  available only in vers 1.0.1 and greater  }
  90.  
  91.  
  92. { parameter to AESend }
  93.  
  94. TYPE
  95.     AESendOptions                        = OptionBits;
  96.  
  97. CONST
  98.     kAENeverInteract            = $00000010;                    {  server should not interact with user  }
  99.     kAECanInteract                = $00000020;                    {  server may try to interact with user  }
  100.     kAEAlwaysInteract            = $00000030;                    {  server should always interact with user where appropriate  }
  101.     kAECanSwitchLayer            = $00000040;                    {  interaction may switch layer  }
  102.     kAEDontRecord                = $00001000;                    {  don't record this event - available only in vers 1.0.1 and greater  }
  103.     kAEDontExecute                = $00002000;                    {  don't send the event for recording - available only in vers 1.0.1 and greater  }
  104.     kAEProcessNonReplyEvents    = $00008000;                    {  allow processing of non-reply events while awaiting synchronous AppleEvent reply  }
  105.  
  106.  
  107. TYPE
  108.     AESendMode                            = SInt32;
  109.  
  110. CONST
  111.     kAENoReply                    = $00000001;                    {  sender doesn't want a reply to event  }
  112.     kAEQueueReply                = $00000002;                    {  sender wants a reply but won't wait  }
  113.     kAEWaitReply                = $00000003;                    {  sender wants a reply and will wait  }
  114.     kAEDontReconnect            = $00000080;                    {  don't reconnect if there is a sessClosedErr from PPCToolbox  }
  115.     kAEWantReceipt                = $00000200;                    {  (nReturnReceipt) sender wants a receipt of message  }
  116.  
  117.  
  118. { Constants for timeout durations }
  119.     kAEDefaultTimeout            = -1;                            {  timeout value determined by AEM  }
  120.     kNoTimeOut                    = -2;                            {  wait until reply comes back, however long it takes  }
  121.  
  122.  
  123. { priority param of AESend }
  124.  
  125. TYPE
  126.     AESendPriority                        = SInt16;
  127.  
  128. CONST
  129.     kAENormalPriority            = $00000000;                    {  post message at the end of the event queue  }
  130.     kAEHighPriority                = $00000001;                    {  post message at the front of the event queue (same as nAttnMsg)  }
  131.  
  132.  
  133.  
  134. TYPE
  135.     AEEventSource                        = SInt8;
  136.  
  137. CONST
  138.     kAEUnknownSource            = 0;
  139.     kAEDirectCall                = 1;
  140.     kAESameProcess                = 2;
  141.     kAELocalProcess                = 3;
  142.     kAERemoteProcess            = 4;
  143.  
  144.  
  145.  
  146.  
  147. TYPE
  148.     AEEventHandlerProcPtr = ProcPtr;  { FUNCTION AEEventHandler((CONST)VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; handlerRefcon: UInt32): OSErr; }
  149.  
  150.     AEIdleProcPtr = ProcPtr;  { FUNCTION AEIdle(VAR theEvent: EventRecord; VAR sleepTime: LONGINT; VAR mouseRgn: RgnHandle): BOOLEAN; }
  151.  
  152.     AEFilterProcPtr = ProcPtr;  { FUNCTION AEFilter(VAR theEvent: EventRecord; returnID: LONGINT; transactionID: LONGINT; (CONST)VAR sender: AEAddressDesc): BOOLEAN; }
  153.  
  154.     AEEventHandlerUPP = UniversalProcPtr;
  155.     AEIdleUPP = UniversalProcPtr;
  156.     AEFilterUPP = UniversalProcPtr;
  157.  
  158. CONST
  159.     uppAEEventHandlerProcInfo = $00000FE0;
  160.     uppAEIdleProcInfo = $00000FD0;
  161.     uppAEFilterProcInfo = $00003FD0;
  162.  
  163. FUNCTION NewAEEventHandlerProc(userRoutine: AEEventHandlerProcPtr): AEEventHandlerUPP;
  164.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  165.     INLINE $2E9F;
  166.     {$ENDC}
  167.  
  168. FUNCTION NewAEIdleProc(userRoutine: AEIdleProcPtr): AEIdleUPP;
  169.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  170.     INLINE $2E9F;
  171.     {$ENDC}
  172.  
  173. FUNCTION NewAEFilterProc(userRoutine: AEFilterProcPtr): AEFilterUPP;
  174.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  175.     INLINE $2E9F;
  176.     {$ENDC}
  177.  
  178. FUNCTION CallAEEventHandlerProc({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; handlerRefcon: UInt32; userRoutine: AEEventHandlerUPP): OSErr;
  179.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  180.     INLINE $205F, $4E90;
  181.     {$ENDC}
  182.  
  183. FUNCTION CallAEIdleProc(VAR theEvent: EventRecord; VAR sleepTime: LONGINT; VAR mouseRgn: RgnHandle; userRoutine: AEIdleUPP): BOOLEAN;
  184.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  185.     INLINE $205F, $4E90;
  186.     {$ENDC}
  187.  
  188. FUNCTION CallAEFilterProc(VAR theEvent: EventRecord; returnID: LONGINT; transactionID: LONGINT; {CONST}VAR sender: AEAddressDesc; userRoutine: AEFilterUPP): BOOLEAN;
  189.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  190.     INLINE $205F, $4E90;
  191.     {$ENDC}
  192.  
  193. {*************************************************************************
  194.   The next couple of calls are basic routines used to create, send,
  195.   and process AppleEvents. 
  196. *************************************************************************}
  197. FUNCTION AESend({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP): OSErr;
  198.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  199.     INLINE $303C, $0D17, $A816;
  200.     {$ENDC}
  201. FUNCTION AEProcessAppleEvent({CONST}VAR theEventRecord: EventRecord): OSErr;
  202.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  203.     INLINE $303C, $021B, $A816;
  204.     {$ENDC}
  205.  
  206.  Note: during event processing, an event handler may realize that it is likely
  207.  to exceed the client's timeout limit. Passing the reply to this
  208.  routine causes a wait event to be generated that asks the client
  209.  for more time. 
  210. }
  211. FUNCTION AEResetTimer({CONST}VAR reply: AppleEvent): OSErr;
  212.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  213.     INLINE $303C, $0219, $A816;
  214.     {$ENDC}
  215.  
  216. {*************************************************************************
  217.   The following three calls are used to allow applications to behave
  218.   courteously when a user interaction such as a dialog box is needed. 
  219. *************************************************************************}
  220.  
  221.  
  222. TYPE
  223.     AEInteractAllowed                    = SInt8;
  224.  
  225. CONST
  226.     kAEInteractWithSelf            = 0;
  227.     kAEInteractWithLocal        = 1;
  228.     kAEInteractWithAll            = 2;
  229.  
  230. FUNCTION AEGetInteractionAllowed(VAR level: AEInteractAllowed): OSErr;
  231.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  232.     INLINE $303C, $021D, $A816;
  233.     {$ENDC}
  234. FUNCTION AESetInteractionAllowed(level: AEInteractAllowed): OSErr;
  235.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  236.     INLINE $303C, $011E, $A816;
  237.     {$ENDC}
  238. FUNCTION AEInteractWithUser(timeOutInTicks: LONGINT; nmReqPtr: NMRecPtr; idleProc: AEIdleUPP): OSErr;
  239.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  240.     INLINE $303C, $061C, $A816;
  241.     {$ENDC}
  242.  
  243. {*************************************************************************
  244.   These calls are used to set up and modify the event dispatch table.
  245. *************************************************************************}
  246. FUNCTION AEInstallEventHandler(theAEEventClass: AEEventClass; theAEEventID: AEEventID; handler: AEEventHandlerUPP; handlerRefcon: LONGINT; isSysHandler: BOOLEAN): OSErr;
  247.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  248.     INLINE $303C, $091F, $A816;
  249.     {$ENDC}
  250. FUNCTION AERemoveEventHandler(theAEEventClass: AEEventClass; theAEEventID: AEEventID; handler: AEEventHandlerUPP; isSysHandler: BOOLEAN): OSErr;
  251.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  252.     INLINE $303C, $0720, $A816;
  253.     {$ENDC}
  254. FUNCTION AEGetEventHandler(theAEEventClass: AEEventClass; theAEEventID: AEEventID; VAR handler: AEEventHandlerUPP; VAR handlerRefcon: LONGINT; isSysHandler: BOOLEAN): OSErr;
  255.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  256.     INLINE $303C, $0921, $A816;
  257.     {$ENDC}
  258.  
  259. {*************************************************************************
  260.  The following four calls are available for applications which need more
  261.  sophisticated control over when and how events are processed. Applications
  262.  which implement multi-session servers or which implement their own
  263.  internal event queueing will probably be the major clients of these
  264.  routines. They can be called from within a handler to prevent the AEM from
  265.  disposing of the AppleEvent when the handler returns. They can be used to
  266.  asynchronously process the event (as MacApp does).
  267. *************************************************************************}
  268. FUNCTION AESuspendTheCurrentEvent({CONST}VAR theAppleEvent: AppleEvent): OSErr;
  269.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  270.     INLINE $303C, $022B, $A816;
  271.     {$ENDC}
  272.  Note: The following routine tells the AppleEvent manager that processing
  273.  is either about to resume or has been completed on a previously suspended
  274.  event. The procPtr passed in as the dispatcher parameter will be called to
  275.  attempt to redispatch the event. Several constants for the dispatcher
  276.  parameter allow special behavior. They are:
  277.       - kAEUseStandardDispatch means redispatch as if the event was just
  278.       received, using the standard AppleEvent dispatch mechanism.
  279.       - kAENoDispatch means ignore the parameter.
  280.          Use this in the case where the event has been handled and no
  281.       redispatch is needed.
  282.       - non nil means call the routine which the dispatcher points to.
  283. }
  284. { Constants for Refcon in AEResumeTheCurrentEvent with kAEUseStandardDispatch }
  285.  
  286. CONST
  287.     kAEDoNotIgnoreHandler        = $00000000;
  288.     kAEIgnoreAppPhacHandler        = $00000001;                    {  available only in vers 1.0.1 and greater  }
  289.     kAEIgnoreAppEventHandler    = $00000002;                    {  available only in vers 1.0.1 and greater  }
  290.     kAEIgnoreSysPhacHandler        = $00000004;                    {  available only in vers 1.0.1 and greater  }
  291.     kAEIgnoreSysEventHandler    = $00000008;                    {  available only in vers 1.0.1 and greater  }
  292.     kAEIngoreBuiltInEventHandler = $00000010;                    {  available only in vers 1.0.1 and greater  }
  293.     kAEDontDisposeOnResume        = $80000000;                    {  available only in vers 1.0.1 and greater  }
  294.  
  295. { Constants for AEResumeTheCurrentEvent }
  296.     kAENoDispatch                = 0;                            {  dispatch parameter to AEResumeTheCurrentEvent takes a pointer to a dispatch  }
  297.     kAEUseStandardDispatch        = $FFFFFFFF;                    {  table, or one of these two constants  }
  298.  
  299. FUNCTION AEResumeTheCurrentEvent({CONST}VAR theAppleEvent: AppleEvent; {CONST}VAR reply: AppleEvent; dispatcher: AEEventHandlerUPP; handlerRefcon: LONGINT): OSErr;
  300.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  301.     INLINE $303C, $0818, $A816;
  302.     {$ENDC}
  303. FUNCTION AEGetTheCurrentEvent(VAR theAppleEvent: AppleEvent): OSErr;
  304.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  305.     INLINE $303C, $021A, $A816;
  306.     {$ENDC}
  307. FUNCTION AESetTheCurrentEvent({CONST}VAR theAppleEvent: AppleEvent): OSErr;
  308.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  309.     INLINE $303C, $022C, $A816;
  310.     {$ENDC}
  311.  
  312. {*************************************************************************
  313.   These calls are used to set up and modify special hooks into the
  314.   AppleEvent manager.
  315. *************************************************************************}
  316. FUNCTION AEInstallSpecialHandler(functionClass: AEKeyword; handler: UniversalProcPtr; isSysHandler: BOOLEAN): OSErr;
  317.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  318.     INLINE $303C, $0500, $A816;
  319.     {$ENDC}
  320. FUNCTION AERemoveSpecialHandler(functionClass: AEKeyword; handler: UniversalProcPtr; isSysHandler: BOOLEAN): OSErr;
  321.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  322.     INLINE $303C, $0501, $A816;
  323.     {$ENDC}
  324. FUNCTION AEGetSpecialHandler(functionClass: AEKeyword; VAR handler: UniversalProcPtr; isSysHandler: BOOLEAN): OSErr;
  325.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  326.     INLINE $303C, $052D, $A816;
  327.     {$ENDC}
  328.  
  329. {*************************************************************************
  330.   This call was added in version 1.0.1. If called with the keyword
  331.   keyAERecorderCount ('recr'), the number of recorders that are
  332.   currently active is returned in 'result'
  333.   (available only in vers 1.0.1 and greater).
  334. *************************************************************************}
  335. FUNCTION AEManagerInfo(keyWord: AEKeyword; VAR result: LONGINT): OSErr;
  336.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  337.     INLINE $303C, $0441, $A816;
  338.     {$ENDC}
  339.  
  340.  
  341. {$ALIGN RESET}
  342. {$POP}
  343.  
  344. {$SETC UsingIncludes := AppleEventsIncludes}
  345.  
  346. {$ENDC} {__APPLEEVENTS__}
  347.  
  348. {$IFC NOT UsingIncludes}
  349.  END.
  350. {$ENDC}
  351.